iT邦幫忙

0

解決PostgreSQL無法遠端訪問的情況 (pg_hba.conf 組態檔)

  • 分享至 

  • xImage
  •  

版本: PostgreSQL14

今天剛入手這個資料庫玩玩,發現無法通過IP去訪問資料庫,
後面查詢原因為,該資料庫預設只能通過本地連線,也就是迴環地址(127.0.0.1)

該檔案位於初始化安裝的資料庫目錄下
編輯** pg_hba.conf** 組態檔

![https://ithelp.ithome.com.tw/upload/images/20220912/20152106wc0bnmGuxH.jpg

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             0.0.0.0/0        trust
host    all             all             0.0.0.0/0        md5
host    all             all             127.0.0.1/32            md5
host    all             all             localhost        trust

# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256
host    all             all             ::0/0        md5

參考來源: https://docs.postgresql.tw/server-administration/client-authentication/the-pg_hba.conf-file


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言